import { toSuccess, useTransaction } from "@sker/core"
import { SysAddon } from "@sker/entities"
import { useReqQuery } from "@sker/runtime"
import { z } from "zod"

export default async () => {
    const input = z.object({
        name: z.string(),
    })
    const body = input.parse(useReqQuery())
    const setting = await useTransaction(async m => {
        const sysAddon = await m.findOne(SysAddon, { where: { name: body.name } })
        return sysAddon?.setting || {};
    })
    return toSuccess(setting)
}
